import { 
    getBannerRequest,
    getRecommendListRequest
} from "@/api/request"
import * as actionTypes from './constance'
export const changeBannerList =(data)=>(
    {
        type:actionTypes.CHANGE_BANNER,
        data:data
    }
)

export const getBannerList=()=>{
    return (dispatch)=>{
        getBannerRequest().then(data=>{
                const action=changeBannerList(data.banners)
                dispatch(action)
            })
    }
}

export const changeRecommendList =(data)=>(
    {
        type:actionTypes.CHANGE_RECOMMEND_LIST,
        data
    }
)

export const getRecommendList =(data)=>{
    return (dispatch)=>{
        getRecommendListRequest().then(data=>{
            dispatch(changeRecommendList(data.result))
            dispatch(changeEnterLoading(false))
        })
         
    }
}

export const changeEnterLoading=(data)=>({
    type:actionTypes.CHANGE_ENTER_LOADING,
    data
})